package com.hl.springboothome1.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class R {
    private int code;
    private String msg;
    private Object data;

    public static R ok(Object obj){
        R r = new R();
        r.setCode(1);
        r.setMsg("success!!");
        r.setData(obj);
        return r;
    }
    public static R fail(){
        R r = new R();
        r.setCode(0);
        r.setMsg("fail!!");
        r.setData(null);
        return r;
    }

    public static R error(){
        R r = new R();
        r.setCode(-1);
        r.setMsg("error!!");
        r.setData(null);
        return r;
    }

}
